package net.lzzy.arraylist;

public class GenericMethodDemo {
  public static void main(String[] args ) {
    Integer[] integers = {1, 2, 3, 4, 5};
    String[] strings = {"London", "Paris", "New York", "Austin"};
    /* Double 类*/
    Double[] doubles1 = {1.1,2.1,3.1,4.1,5.1};

    GenericMethodDemo.<Integer>print(integers);
    GenericMethodDemo.<String>print(strings);
    GenericMethodDemo.<Double>print(doubles1);

    /* 学生类 */
    Student s1 = new Student("张浩","男",20);
    Student[] students = new Student[]{s1};
    print(students);

    /* 电脑类*/
    Computer com = new Computer(101,"拯救者","512G");
    Computer[] computers = new Computer[]{com};
    print(computers);

  }
  public static <E> void print(E[] list) {
    for (int i = 0; i < list.length; i++){
      System.out.print(list[i] + " ");
    }

    System.out.println();
  }
}
